﻿using System;
using System.Runtime.Serialization;
using Microsoft.Maps.MapControl;


namespace SMIL.InfoTool
{
    [DataContract]
    public class InfoToolParams
    {

        [DataMember]
        public string Title { get; set; }
        [DataMember]
        public string Subtitle { get; set; }
        [DataMember]
        public string IconUrl { get; set; }
        [DataMember]
        public string ObjectUrl { get; set; }
        [DataMember]
        public Guid Guid { get; set; }
        [DataMember]
        public string WKT { get; set; }
        //[DataMember]
        //public string Status { get; set; }

        //public MapLayer Layer { get; set; }

        [DataMember]
        public string ViewName { get; set; }
        [DataMember]
        public string[] ViewNames { get; set; }
        [DataMember]
        public string ListName { get; set; }
        [DataMember]
        public string SPSiteURI { get; set; }
        [DataMember]
        public string SPItemID { get; set; }

        public string toXML()
        {
            //Create a stream to serialize the object to.
            System.IO.MemoryStream ms = new System.IO.MemoryStream();

            // Serializer the User object to the stream.
            DataContractSerializer ser = new DataContractSerializer(typeof(InfoToolParams));
            ser.WriteObject(ms, this);
            byte[] array = ms.ToArray();
            ms.Close();
            return System.Text.Encoding.UTF8.GetString(array, 0, array.Length);
        }


        public static InfoToolParams fromXML(string strXML)
        {
            System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(System.Text.Encoding.Unicode.GetBytes(strXML));

            DataContractSerializer ser = new DataContractSerializer(typeof(InfoToolParams));

            // Deserialize the data and read it from the instance.
            InfoToolParams i = (InfoToolParams)ser.ReadObject(memoryStream);
            memoryStream.Close();
            return i;
        }

    
    }
}
